package com.hy.admin.enums;

import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableMap;

/**
 * Created by wayne on 18/4/22.
 */
public enum  EnumPayModel {
    WECHAT_MICROPAY(104,"微信APP支付","WechatAPP"),
    WECHAT_JSAPIPAY(105,"微信公众号支付","WechatJSAPI"),
        ;
    private int id;
    private String value;
    private String code;

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getValue() {
        return value;
    }

    public void setValue(String value) {
        this.value = value;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    EnumPayModel(final int id, final String code, final String value) {
        this.id = id;
        this.code=code;
        this.value = value;
    }

    private static final ImmutableMap<Integer, EnumPayModel> INIT_MAP;


    static {
        final ImmutableMap.Builder<Integer, EnumPayModel> builder = new ImmutableMap.Builder<>();
        for (EnumPayModel status : EnumPayModel.values()) {
            builder.put(status.getId(), status);
        }
        INIT_MAP = builder.build();
    }

    public static EnumPayModel of(final int status) {
        Preconditions.checkState(INIT_MAP.containsKey(status), "unknown status[{}]", status);
        return INIT_MAP.get(status);
    }
}
